<template>
  <div :class="styles['all-put-store']">
    <div class="ato-flex-jc-end">
      <UidSearchBar tips="输入销售订单UID或发货物流单号，可搜索已发货订单信息：">
        <el-form inline :model="searchForm" :rules="searchRules" style="margin-top: 6px">
          <el-form-item label="物流单号:" prop="orderUID">
            <el-input v-model="searchForm.orderUID" placeholder="物流单号" clearable style="width: 200px"/>
          </el-form-item>
          <el-form-item label="送卡订单UID:" prop="cardUID">
            <el-input v-model="searchForm.cardUID" placeholder="送卡订单UID" clearable style="width: 200px"/>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="handleSearch">搜索</el-button>
            <el-button type="primary" @click="handleSearch(true)">重置</el-button>
          </el-form-item>
        </el-form>
      </UidSearchBar>
    </div>
    <hr class="ato-mt-16 ato-mb-16"/>
    <h2 class="ato-title ato-mb-12">全部已入库订单:</h2>
    <EnterStoreList :wms-status="5" @wmsHandle="wmsHandle" ref="enterStoreListRef"/>
    <el-drawer v-model="detail.open" :with-header="false" size="100%" destroy-on-close :show-close="false" :close-on-press-escape="false">
      <EnterStoreDetail
          disabled
          prop="allPutStore"
          :trackingNo="detail.trackingNo"
          :orderNo="detail.orderNo"
          @close="detail.open = false"
      />
    </el-drawer>
  </div>
</template>

<script setup name="AllPutStore">
import {reactive, ref} from 'vue'
import { UidSearchBar, EnterStoreList, EnterStoreDetail } from '@/components'

// 详情页
const detail = reactive({
  open: false,
  trackingNo: '',
  orderNo: ''
})

// 列表组件
const enterStoreListRef = ref(null)

// 搜索表单
const searchForm = reactive({
  trackingNo: '',
  orderNo: ''
})

// 搜索按钮
function handleSearch (isReset = false) {
  if (isReset) {
    searchForm.orderNo = ''
    searchForm.cardUID = ''
  }
  enterStoreListRef.value.onLoad({
    trackingNo: searchForm.trackingNo,
    orderNo: searchForm.orderNo
  })
}

// 状态操作按钮
function wmsHandle ({trackingNo, orderNo}) {
  detail.open = true
  detail.trackingNo = trackingNo
  detail.orderNo = orderNo
}

</script>

<style lang="less" src="./index.less" module="styles"></style>
